package com.gulimall.coupon.controller;

import com.gulimall.common.utils.ServiceResponse;
import com.gulimall.coupon.api.dto.CouponInDTO;
import com.gulimall.coupon.api.dto.CouponOutDTO;
import com.gulimall.coupon.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 优惠券信息
 *
 * @author aliuql
 * @email 17701057157@qq.com
 * @date 2021-11-16 09:26:07
 */
@RestController
@RequestMapping("/coupon/coupon")
@RefreshScope
public class CouponController {

    @Autowired
    private CouponService couponService;

    /**
     * 获取详情
     */
    @GetMapping("/getDetail")
    public ServiceResponse<CouponOutDTO> getDetail(@RequestParam("id") Long id) {
        return couponService.getDetail(id);
    }

    /**
     * 获取明细列表
     */
    @GetMapping("/getList")
    public ServiceResponse<CouponOutDTO> getList(@RequestBody CouponInDTO couponInDTO) {
        return couponService.getList(couponInDTO);
    }

    /**
     * 获取明细列表(分页)
     */
    @GetMapping("/getPage")
    public ServiceResponse<CouponOutDTO> getPage(@RequestBody CouponInDTO couponInDTO) {
        return couponService.getPage(couponInDTO);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public ServiceResponse<Void> save(@RequestBody CouponInDTO couponInDTO) {
        return couponService.save(couponInDTO);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public ServiceResponse<Void> update(@RequestBody CouponInDTO couponInDTO) {
        return couponService.update(couponInDTO);
    }

    /**
     * 批量删除
     */
    @PostMapping("/deleteBatch")
    public ServiceResponse<Void> deleteBatch(@RequestBody List<Long> ids) {
        return couponService.deleteBatch(ids);
    }
}
